package com.bi.autotest.pages.payprocesspage;

import com.auto.base.PageAppium;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidElement;
import org.openqa.selenium.By;
/**
 *  营销页面
 */
public class MarketPage extends PageAppium {

    public final String TO_LOGIN_SUCCESSPAGE = "账目查询";
    public final String ISCACHE_SUCCESSPAGE = "//*[@id=\"tab1\"]/div[2]/a";
    public final String MY_VIP = "我的会员";
    public final String USER_1 = "//*[@id=\"receipts_order_list\"]/li[1]/a/div/div[1]";
    public final String TO_MARKETING = "/html/body/div/div/div/div[4]/div[2]/ul/a";
    public final String CIS_XP = "/html/body/div/div/div/div[2]/div[2]/a[1]";//消费立减
    public final String CIS_INPUT_XP = "//*[@id=\"amount\"]";//立减金额
    public final String CIS_GIVEOUT_BUTTON_XP = "//*[@id=\"rebateButton\"]";//立减,发放按钮
    public final String CIS_CONFIRM_BUTTON_XP = "//*[@id=\"rebateBtn\"]";//立减,确认发放

    public final String DISCOUNT_XP = "/html/body/div/div/div/div[2]/div[2]/a[2]";//折扣优惠
    public final String DISCOUNT_INPUT_XP = "//*[@id='discount']";//折扣力度
    public final String TIMES_INPUT_XP = "//*[@id='count']";//折扣次数
    public final String DISCOUNT_GIVEOUT_BUTTON_XP = "//*[@id='discountButton']";//折扣，发放按钮
    public final String Discount_CONFIRM_BUTTON_XP = "//*[@id='discountBtn']";//折扣，确认发放

    public final String GIVEOUT_SUCCESS = "/html/body/div[4]/div[1]/div";
    public final String AGREEMENT_CONFIRM = "/html/body/div[3]/div[2]/span[2]";//协议声明确认



    public MarketPage(AndroidDriver androidDriver) {
        super(androidDriver);
    }

    public boolean isLoginPage() {
        return isXpathExistText(By.xpath(ISCACHE_SUCCESSPAGE), MY_VIP, 5, false);
    }

    public AndroidElement getUser_1() {
        return waitAutoByXp(USER_1, 5);
    }

    public AndroidElement getMarketing() {
        return waitAutoByXp(TO_MARKETING, 5);
    }


    /**
     * 立减
     */
    public AndroidElement getCIS() {
        return waitAutoByXp(CIS_XP, 5);
    }

    public AndroidElement getCISInput() {
        return waitAutoByXp(CIS_INPUT_XP, 5);
    }

    public AndroidElement getCISGiveOutButton() {
        return waitAutoByXp(CIS_GIVEOUT_BUTTON_XP, 5);
    }

    public AndroidElement getCISConfirmButton() {
        return waitAutoByXp(CIS_CONFIRM_BUTTON_XP, 5);
    }


    /**
     * 折扣
     */
    public AndroidElement getDiscount() {
        return waitAutoByXp(DISCOUNT_XP, 5);
    }

    public AndroidElement getDiscountInput() {
        return waitAutoByXp(DISCOUNT_INPUT_XP, 5);
    }

    public AndroidElement getTimesInput() {
        return waitAutoByXp(TIMES_INPUT_XP, 5);
    }

    public AndroidElement getDiscountGiveOutButton() {
        return waitAutoByXp(DISCOUNT_GIVEOUT_BUTTON_XP, 5);
    }

    public AndroidElement getDiscountConfirmButton() {
        return waitAutoByXp(Discount_CONFIRM_BUTTON_XP, 5);
    }


    public boolean isGiveOutSuccess(String text) {
        return isXpathExistText(By.xpath(GIVEOUT_SUCCESS), text, 5, false);
    }

    public AndroidElement getAgreementConfirm() {
        return waitAutoByXp(AGREEMENT_CONFIRM, 5);
    }
}
